package net.lovesrc.allin.biz.dida;

import com.google.common.collect.Lists;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class ForecastListing implements Comparable<ForecastListing>, Serializable {

    private ListingHolder holder;

    private Listing listing;

    private List<String> days = Lists.newArrayList();

    public ForecastListing() {
    }

    public ForecastListing(ListingHolder holder, List<String> days) {
        this.holder = holder;
        this.listing = holder.getOrigin();
        this.days = days;
    }

    @Override
    public int hashCode() {
        return holder.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ForecastListing)) {
            return false;
        }
        return ((ForecastListing) o).holder.equals(holder);
    }

    @Override
    public int compareTo(ForecastListing o) {
        return days.size() > o.days.size() ? -1 : 1;
    }

}
